/**
 * 
 */
package com.kunbo.cn.controller.core.card;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kunbo.cn.entity.core.card.ICCard;
import com.kunbo.cn.service.core.card.ICCardService;
import com.kunbo.cn.util.date.SDate;
import com.kunbo.cn.util.retu.CommonResult;

/**
 *
 * @author bjl  
 * @date 2019年3月21日 
 */
@RestController
@RequestMapping("/ICCard/")
public class ICCardController {
	@Autowired
	private JdbcTemplate jdbc;
	@Autowired
	private ICCardService ICservice;
	/**
	 * 添加手持机用户
	 * 
	 */
	@PostMapping("/add")
	public CommonResult add(ICCard ic) {
		ICservice.save(ic);
		return new CommonResult(true,"操作成功",null);
	}
	@GetMapping("/createCode")
	public String createCode(){
		 String prex = "IC";
		 String bill_code= prex+SDate.getSystemDateYMDHMSToString();
		 return bill_code;
	}
	@GetMapping("/cardSerial")
	public String getCardSerial(){
		 String prex = "CY";
		 String card_serial= prex+SDate.getSystemDateYMDHMSToString();
		 return card_serial;
	}
		/**
		 * 
		 * 修改
		 */
		@PutMapping("/update")
		public CommonResult update(ICCard ic) {
			ICservice.update(ic);
			return new CommonResult(true,"操作成功",null);
		}
		
		@DeleteMapping("/delete")
		public CommonResult delete(String id) {
			ICservice.delete(id);
			return new CommonResult(true,"操作成功",null);
		}
		/**
		 * 详情
		 * 
		 */
		@GetMapping("/findById")
		public ICCard findById(String id) {
			ICCard d = ICservice.findById(id);
			return d;
		}
		
		/**
		 *条件分页查询
		 * 
		 */
		@GetMapping("/findICCard")
		public Page<ICCard> findICCard(String bill_code,String ic_code,String card_serial,Integer pageNo,Integer pageSize) {
			Page<ICCard> page = ICservice.findICCard(bill_code, ic_code,card_serial,pageNo, pageSize);
			return page;
		}
	

}
